module.exports = function (mongoose, Schema, ObjectId) {
  let artcleSchema = new Schema({
    title: {
      type: String,
      required: [true, '缺少标题。'],
      maxlength: [30, '标题太长了。']
    },
    content: {
      type: String,
      required: [true, '缺少内容。'],
      maxlength: [2000, '内容太长了。']
    },
    author: {
      type: ObjectId,
      ref: 'User',
      required: true
    },
    views: {
      type: Number,
      default: 0
    },
    blog: {
      type: ObjectId,
      ref: 'Blog',
      required: true
    },
    createAt: {
      type: Date,
      default: Date.now
    },
    updateAt: {
      type: Date,
      default: Date.now
    }
  })

  return mongoose.model('Artcle', artcleSchema)
}
